package com.scuec.demo.mapper;

import com.scuec.demo.entity.StudentInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.Mapping;

import java.util.List;
//https://gitee.com/li-xue-yuan/student-manger-sys.git
@Mapper
public interface StudentMapper {

    @Select("SELECT * FROM world.student_info")
    List<StudentInfo> findStudentInfo();

    @Select("select * from student_info")
      List<StudentInfo> getStudentInfo();

    @Select("select * from student_info where stuid= #{id}")
      StudentInfo getStudentInfoById(Integer id);


    @Delete("delete from student_info where stuid= #{id}")
      int deleteStudentInfoById(Integer id);

    @Insert("insert into student_info (stu_no,stu_name,stu_sex,stu_birthday,stu_education,my_color,create_date,clsid) \n" +
            "        values(#{stu_no},#{stu_name},#{stu_sex},#{stu_birthday},#{stu_education},#{my_color},sysdate(),#{clsid})")
      int insertStudentInfo(StudentInfo studentInfo);

    @Update("update student_info set " +
            "stu_no=#{stu_no}, " +
            "stu_name=#{stu_name}, " +
            "stu_sex=#{stu_sex}, " +
            "stu_birthday=#{stu_birthday}, " +
            "stu_education=#{stu_education}, " +
            "my_color=#{my_color}, " +
            "clsid=#{clsid} " +  // 注意此处末尾添加空格
            "where stuid=#{stuid}")
    public int updateStudentInfo(StudentInfo studentInfo);


}
